package com.googlecode.messwertepi.module;

import com.google.inject.Inject;
import com.googlecode.messwertepi.util.GpioPin;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioPinDigital;
import com.pi4j.io.gpio.PinPullResistance;

/**
 * This factory provides access to the gpio pins.
 *
 * Created by eike on 19.07.14.
 */
public class GpioPinFactory {

    final private GpioController gpio;

    @Inject
    public GpioPinFactory(GpioController gpio) {
        this.gpio = gpio;
    }

    public GpioPinDigital createInstance(GpioPin gpioPin) {
        return gpio.provisionDigitalInputPin(gpioPin.getPin(), PinPullResistance.PULL_DOWN);
    }
}